package com.linkq.ipinyin.dao;

import com.linkq.core.base.BaseDao;
import com.linkq.ipinyin.model.Text;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Repository;

/**
 * @FileName BcTextDao
 * @Description
 * @Author wangpeng
 * @date 2024-11-12
 **/

@Repository
public class TextDao extends BaseDao<Text> {
    public String queryBcTextAndFile(Text text) {
        StringBuilder sql = new StringBuilder();
        sql.append(" select * from bc_text t");
        sql.append(" left join bc_file f on t.picture_id = f.id or t.video_id = f.id");
        sql.append(" where 1=1");
        if (StringUtils.isNotBlank(text.getTitle())){
            sql.append(" and t.title like '%").append(text.getTitle()).append("%'");
        }
        if (null != text.getGrade()) {
            sql.append(" and t.grade = ").append(text.getGrade());
        }
        return sql.toString();
    }
}
